#pragma  once
#include <QGraphicsItem>

using namespace std;

class Node;

//class TreeModel;

class Title : public QGraphicsItem{
private:
	
public:
	Title(QGraphicsItem *_source, QString _title, QPointF _pos);
	void adjust();
	QRectF boundingRect() const;
	void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
	void setTitle(QString _text){ text = _text; size = QRectF(0, 0, text.length() * 6.5, 20); update();}
	QString title(){ return text; }
protected:
	void mousePressEvent(QGraphicsSceneMouseEvent *event);
	void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
	void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
private:
	QRectF size;
	QGraphicsItem *source;
	QPointF sourcePos;
	QPointF position;
	QString text;
signals:
	void selectionChanged();
};
